<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>

		<link rel="stylesheet" href="${pageContext.request.contextPath}/main/css/amazeui.min.css">
		<link rel="stylesheet" href="${pageContext.request.contextPath}/main/css/admin.css">
		<link rel="stylesheet" href="${pageContext.request.contextPath}/main/css/app.css">
	</head>

	<body>

		<div class="am-cf admin-main">
			<!-- content start -->
			<div class="admin-content">
				<div class="admin-content-body">
					<div class="am-cf am-padding am-padding-bottom-0">
						<div class="am-fl am-cf">
							<strong class="am-text-primary am-text-lg"> </strong><small>
								<i class="icon-home"></i> &gt; 首页 &gt; 还款申请</small>
						</div>
					</div>
					<hr>
					<div class="container">
						<div class="am-g">
							<div class="am-u-sm-12 am-u-md-6">
							</div>
							<div class="am-u-sm-12 am-u-md-3">

								<select id="selDepart" data-am-selected="{btnSize: 'sm'}" style="display: none;">
									<option value="0">
										请选择类型
									</option>

									<option value="14">
										研发部
									</option>

									<option value="22">
										市场部
									</option>

								</select>
								<div class="am-selected am-dropdown " id="am-selected-dhh2q" data-am-dropdown=""> <button type="button" class="am-selected-btn am-btn am-dropdown-toggle am-btn-sm am-btn-default">    <span class="am-selected-status am-fl">请选择类型</span>    <i class="am-selected-icon am-icon-caret-down"></i>  </button>
									<div class="am-selected-content am-dropdown-content">
										<h2 class="am-selected-header"><span class="am-icon-chevron-left">返回</span></h2>
										<ul class="am-selected-list">
											<li class="am-checked" data-index="0" data-group="0" data-value="0"> <span class="am-selected-text">请选择类型</span> <i class="am-icon-check"></i></li>
											<li class="" data-index="1" data-group="0" data-value="14"> <span class="am-selected-text">研发部</span> <i class="am-icon-check"></i></li>

										</ul>
										<div class="am-selected-hint"></div>
									</div>
								</div>
								<div class="am-selected am-dropdown " id="am-selected-z6ofo" data-am-dropdown="">
									<button style="display: none;" type="button" class="am-selected-btn am-btn am-dropdown-toggle am-btn-sm am-btn-default">
										<span class="am-selected-status am-fl">请选择类型</span>
										<i class="am-selected-icon am-icon-caret-down"></i>
									</button>
									<div class="am-selected-content am-dropdown-content">
										<h2 class="am-selected-header">
											<span class="am-icon-chevron-left">返回</span>
										</h2>
										<ul class="am-selected-list">
											<li class="am-checked" data-index="0" data-group="0" data-value="option1">
												<span class="am-selected-text">请选择部门</span>
												<i class="am-icon-check"></i>
											</li>

											<li class="" data-index="1" data-group="0" data-value="option2">
												<span class="am-selected-text">研发部</span>
												<i class="am-icon-check"></i>
											</li>

											<li class="" data-index="1" data-group="0" data-value="option2">
												<span class="am-selected-text">市场部</span>
												<i class="am-icon-check"></i>
											</li>

											<li class="" data-index="1" data-group="0" data-value="option2">
												<span class="am-selected-text">渠道一部</span>
												<i class="am-icon-check"></i>
											</li>

											<li class="" data-index="1" data-group="0" data-value="option2">
												<span class="am-selected-text">教学部</span>
												<i class="am-icon-check"></i>
											</li>

											<li class="" data-index="1" data-group="0" data-value="option2">
												<span class="am-selected-text">教务部</span>
												<i class="am-icon-check"></i>
											</li>

											<li class="" data-index="1" data-group="0" data-value="option2">
												<span class="am-selected-text">渠道二部</span>
												<i class="am-icon-check"></i>
											</li>

											<li class="" data-index="1" data-group="0" data-value="option2">
												<span class="am-selected-text">渠道三部</span>
												<i class="am-icon-check"></i>
											</li>

										</ul>
										<div class="am-selected-hint"></div>
									</div>
								</div>
							</div>

							<div class="am-u-sm-12 am-u-md-3">
								<div class="am-input-group am-input-group-sm">
									<input class="am-form-field" placeholder="请输入搜索内容" id="username" type="text">
									<span class="am-input-group-btn">
										<button class="am-btn am-btn-default" type="button" id="btnsearch">
											搜索
										</button> </span>
								</div>
							</div>
						</div>
						<div class="am-g" style="margin-top: -30px;">
							<div class="am-u-sm-12">
								<form class="am-form" action="user/delAll.action">
									<table class="am-table am-table-striped am-table-hover table-main">
										<thead>
											<tr>
												<th class="table-check">
													<input id="chkAll" type="checkbox">
												</th>
												<th class="table-id">
													ID
												</th>
												<th>
													请求名
												</th>
												<th class="table-title">
													用途
												</th>
												<th>
													企业名称
												</th>
												<th>
													融资金额
												</th>
												<th>
													融资工具
												</th>
												<th>
													融资产品
												</th>
												<th>
													请求日期
												</th>
												<th>
													请求状态
												</th>
												<th>
													请求意见
												</th>
												<th class="table-set">
													操作
												</th>
											</tr>
										</thead>
										<tbody id="tUser">
									    <c:forEach items="${financeList}" var="finance" varStatus="status">
								            <tr>
								                <td>${status.count}</td>
								                <td>${finance.reqId}</td>
								                <td>${finance.reqName}</td>
								                <td>${finance.purpose}</td>
								                <td>${finance.name}</td>
								                <td>${finance.reqAmount}</td>
								                <td>${finance.reqTool}</td>
								                <td>${finance.product}</td>
								                <td>${finance.reqDate}</td>
								                <td>
								                <c:choose>
												    <c:when test="${finance.reqStatus eq 1}">待处理</c:when>
												    <c:when test="${finance.reqStatus eq 2}">等待商业银行审批</c:when>
												    <c:when test="${finance.reqStatus eq 3}">请求通过，等待放款</c:when>
												    <c:when test="${finance.reqStatus eq 4}">放款完成，等待还款</c:when>
												    <c:when test="${finance.reqStatus eq 5}">还款完成</c:when>
												    <c:otherwise>未知状态</c:otherwise>
												</c:choose>
								                </td>
								                <td>${finance.reqMassage}</td>
								                <td>
													<div class="am-btn-toolbar" >
														<div class="am-btn-group am-btn-group-xs" ><button type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary btnEdit" onclick="returnReq(${finance.reqId})"><span class="am-icon-pencil-square-o" ></span>还款</button></div>
													</div>
												</td>
								            </tr>
								        </c:forEach>

										</tbody>
									</table>

								</form>
							</div>
						</div>
					</div>

				</div>
				<!-- content end -->
			</div>
		</div>
<script>
function returnReq(reqId) {
    // 执行你的操作
    console.log("还款请求ID：" + reqId);
    
    // 可选：阻止链接的默认行为（跳转）
    var url = "${pageContext.request.contextPath}/ReturnController"; // 替换为你想要跳转的目标页面的URL
    // 拼接URL和请求参数
    var fullUrl = url + "?reqId=" + reqId;
    // 跳转到指定URL
    window.location.href = fullUrl;

}
</script>
<script>
	  // 使用JSTL或EL表达式获取请求是否成功的状态
	  var isRequestSuccess = ${isRequestSuccess};
	  var message = "${message}";
	  console.log(isRequestSuccess + ":" + message);
	
	  // 显示相应的提醒框
	  if (isRequestSuccess) {
	      alert(message);
	  } else {
	      alert(message);
	  }
</script>
		<!--[if lt IE 9]>
<script src="js/jquery.min.js"></script>
<script src="js/modernizr.js"></script>
<script src="js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

		<!--[if (gte IE 9)|!(IE)]><!-->
		<script src="${pageContext.request.contextPath}/main/js/jquery-1.11.3.min.js"></script>
		<!--<![endif]-->
		<script type="text/javascript" src="${pageContext.request.contextPath}/main/js/plugs.js"></script>
		<script>
			$(function() {
				$(".btnAdd").click(function() {
					$.jq_Panel({
						title: "添加用户",
						url: "addUser.html",
						iframeWidth: 800,
						iframeHeight: 600,
					});
				});

				$(".btnEdit").click(function() {
					console.log("点击还款按钮");
		            var param1 = ${finance.reqId}; // 替换为你的请求参数
		            var url = "${pageContext.request.contextPath}/ReturnController"; // 替换为你想要跳转的目标页面的URL
		            console.log("参数：" + param1);
		            // 拼接URL和请求参数
		            var fullUrl = url + "?reqId=" + param1;
		            
		            // 跳转到指定URL
		            window.location.href = fullUrl;
				});

			});
		</script>
	</body>

</html>